/*class Shape {
    //属性....
    public void draw() {
        System.out.println("画图形！");
    }
}

class Rect extends Shape {
    @Override
    public void draw() {
        System.out.println("♦");
    }
}

class Cycle extends Shape {
    @Override
    public void draw() {
        System.out.println("●");
    }
}

class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}

class Triangle extends Shape {
    @Override
    public void draw() {
        System.out.println("△");
    }
}
public class Test2 {
    public static void drawShapes() {
        // 我们创建了一个 Shape 对象的数组.
        Shape[] shapes = {new Cycle(), new Rect(), new Cycle(),
                new Rect(), new Flower()};
        for (Shape shape : shapes) {
            shape.draw();
        }
    }

}*/


import java.nio.charset.StandardCharsets;

/*
判断字符串是否相等
equals();
compareTo();
忽略大小写
compareToIgnoreCase()
找指定位置的字符
charAt()
根据字符找下标
indexOf()
倒序
lastIndexOf()

 */

public class Test2 {
    public static void main(String[] args) {
        String s1 = "abababcabde";
        int index = s1.lastIndexOf("ba");
        System.out.println(index);
        /*int index = s1.indexOf("ab",5);
        System.out.println(index);*/

        /*String s1 = "hello";
        int index = s1.indexOf('o');
        System.out.println(index);*/
    }
    public static void main5(String[] args) {
        String s1 = "hello";
        char ch = s1.charAt(1);
        for (int i = 0; i < s1.length(); i++) {
            char c = s1.charAt(i);
            System.out.println(c);
        }
    }

    public static void main4(String[] args) {
        String s1 = new String("a");
        String s2 = new String("v");
        //忽略大小写比较
        System.out.println(s1.compareToIgnoreCase(s2));
    }
    public static void main3(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("heLlo");
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));
        System.out.println(s1.compareTo(s2));
    }

    public static void main2(String[] args) {
        String s1 = new String("hello");
        String s2 = s1;
        System.out.println(s1);
        System.out.println(s2);
        s2 = "asd";
        System.out.println(s1);
        System.out.println(s2);

        String str4 = "";
        String str5 = null;
        System.out.println(str4.length());
        System.out.println(str4.isEmpty());
        //System.out.println(str5.length());
    }

    public static void main1(String[] args) {
        String str = "hello";
        System.out.println(str);

        String str2 = new String();
        System.out.println(str2);

        String str3 = new String("ppp");
        System.out.println(str3);

        char array[] = {'a','b','c'};
        String str4 = new String(array,1,2);
        System.out.println(str4);
    }
}


















